package com.wanho.java156.restcontoller;

import com.wanho.java156.po.Member;
import com.wanho.java156.service.MemberService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/member")
@Api(value = "会员管理接口",tags = {"短信发送","CRUD"})
public class MemberController {
    @Autowired
    private MemberService memberService ;
    @GetMapping("/sendSmsCode")
    @ApiOperation(value = "发送短信验证码",httpMethod = "GET")
    @ApiImplicitParam(name = "phone",required = true,dataType = "string")
    public String sendSmsCode(String phone){
        return memberService.sendSmsCode(phone) ;
    }

    @GetMapping("/list")
    @ApiOperation(value = "查询所有会员",httpMethod = "GET")
    public List<Member> list(){
        return memberService.selectAll() ;
    }

    @PostMapping("/save")
    @ApiOperation(value = "新增会员",httpMethod = "POST")
    @ApiImplicitParam(name="member",dataTypeClass = Member.class,paramType = "application/json")
    public boolean save(@RequestBody Member member){
        return memberService.save(member) ;
    }

}
